package com.xiaoyu.izf.controller;

import com.xiaoyu.izf.aspect.RequestAuth;
import com.xiaoyu.izf.model.UserInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/")
public class IndexController {

    @RequestMapping("")
    public String index(HttpServletRequest request) {
        return "redirect:/login_page";
    }

    @RequestMapping("/login_page")
    public String loginPage(HttpServletRequest request, Model model) {
        return "/login/login";
    }

    @RequestMapping("/no_permission_page")
    public String noPermissionPage(HttpServletRequest request, Model model) {
        return "/mgr/no_permission";
    }

    @RequestMapping("/main")
    @RequestAuth
    public String main(HttpServletRequest request,Model model) {
        UserInfo user = (UserInfo) request.getAttribute("user");
        String nick = "&nbsp;&nbsp;&nbsp;&nbsp;"+user.getNickName();
        if(user.getIsAdmin()==1){
            nick+="(管理员)";
        }else if(user.getVipType()==1){
            nick+="(运营商)";
        }else if(user.getVipType()==2){
            nick+="(渠道商)";
        }else if(user.getVipType()==3){
            nick+="(推广员)";
        }else if(user.getVipType()==21){
            nick+="(省级服务商)";
        }else if(user.getVipType()==23){
            nick+="(区县服务商)";
        }
        model.addAttribute("nick",nick);
        return "mgr/main";
    }

}
